package uutalk.netcloud.talk.app.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.Settings;
import android.view.View;

import butterknife.OnClick;
import uutalk.netcloud.talk.R;
import uutalk.netcloud.talk.app.ui.Activity.UserInfoActivity;
import uutalk.netcloud.talk.base.android.BaseFragment;
import uutalk.netcloud.talk.base.util.view.ToastUtil;

/**
 * 类描述：
 * 作者：Pengmutian
 * 时间：2018/4/18
 */
public class SecondFragment extends BaseFragment {

    private static final int FILE_SELECT_CODE = 1000;

    public static SecondFragment newInstance() {
        Bundle args = new Bundle();
        SecondFragment fragment = new SecondFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int setLayoutResId() {
        return R.layout.layout_second_fragment;
    }

    @Override
    protected void loadData() {

    }

    @Override
    protected void init() {

    }

    @OnClick({R.id.llSetting, R.id.llCamara, R.id.llFoder, R.id.llUpload})
    public void onViewClick(View view){
        switch (view.getId()){
            case R.id.llSetting:{
                //设置界面
                startActivity(new Intent(Settings.ACTION_SETTINGS)); //直接进入手机中设置界面
            }break;
            case R.id.llCamara:{
                //照相
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivity(intent);
            }break;
            case R.id.llFoder:{
                //文件
                chooseFile();
            }break;
            case R.id.llUpload:{
                //上传
                Intent intent = new Intent(mActivity, UserInfoActivity.class);
                startActivity(intent);
            }break;
        }
    }

    private void chooseFile() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        try {
            startActivityForResult(Intent.createChooser(intent, getString(R.string.file)), FILE_SELECT_CODE);
        } catch (android.content.ActivityNotFoundException ex) {
            ToastUtil.makeToast("亲，木有文件管理器啊-_-!!");
        }
    }
}
